path = ‘C:/Users/shijuntong/Desktop/Walden.txt’
with open(path,‘r’,encoding=‘utf-8’) as text:#读入文本
    words = text.read().split()#开始分词
    print(words)
    for word in words:
        print(’{}–{}
        times’.format(word, words.count(word)))#将单词和词频打印出来
